home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3379 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1002 b 

  1. Path: news.algonet.se!usenet
  2. From: Anders Olofsson <ao@algonet.se>
  3. Newsgroups: comp.lang.c
  4. Subject: Help with linked list needed
  5. Date: 28 Jan 1996 14:31:10 GMT
  6. Organization: AlgoNet Public Access Node, Stockholm
  7. Message-ID: <4eg1be$45o@prometheus.algonet.se>
  8. NNTP-Posting-Host: sophocles.algonet.se
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.22 (Windows; I; 16bit)
  13.  
  14. I have a linked list like this:
  15.  
  16. item_A->item_B->item_C->NULL
  17.  
  18. This list is declared in function main like this:
  19.  
  20. itemptr list;
  21.  
  22. I have a function that deletes the first item in the list
  23.  
  24. void deleteitem (itemptr *l);
  25.  
  26.  
  27.  
  28. Now, if I call deleteitem 3 times from function main with list as
  29. parameter the list will point to NULL.
  30.  
  31. I.e:
  32.  
  33. deleteitem (&list);
  34. deleteitem (&list);
  35. deleteitem (&list);
  36.  
  37. gives:
  38.  
  39. list->NULL
  40.  
  41.  
  42.  
  43. But if I call deleteitem from another function than main it will
  44. not work. How do I overcome this problem???...
  45.  
  46.  
  47. -- Anders Olofsson
  48.    ao@algonet.se
  49.